package com.tool.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import com.tool.service.Base64Service;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;

@RestController
@Api(tags = "base64加密解密")
public class Base64Controller {

	@Autowired
	Base64Service  base64Service;
	
	@GetMapping("/encode/{msg}")
	@ApiOperation("将输入的信息加密后输出密文")
	public String base64Encode(@ApiParam("明文") @PathVariable String msg) {
		return base64Service.encode(msg);
	}
	
	@GetMapping("/decode/{msg}")
	@ApiOperation("将输入密文解密为明文")
	public String base64Decode(@ApiParam("密文") @PathVariable String msg) {
		return new String(base64Service.decode(msg));
	}
}
